function HandleTableRowProducePurchase(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  this._popupBox = new PopupBox();
  this._popupBox2 = new PopupBox2();
  
  this._user = (options && options.user) ? options.user : null;
  this._date = (options && options.date) ? options.date : null;
  this._parent = (options && options.parent) ? options.parent : null;
  this._callbackFunc = (options && options.callbackFunc) ? options.callbackFunc : function() {};
  
  this._createElements();
};

HandleTableRowProducePurchase.prototype._createElements = function() {
  var gui, _self = this;
  DlmanageUtils.clear(this._gui);
  
  var span = document.createElement('span');
  span.style.fontWeight = 'bold';
  span.appendChild(document.createTextNode(this._item.pi_quantity + 'X'));
  this._gui.name.appendChild(span);
  this._gui.name.appendChild(document.createTextNode(this._item.title));
  if (this._item.pi_selects.length > 0 && (this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_VIDEODVD|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_4X6|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_RETOUCH|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_RETOUCH_MAGAZINE|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_COMMON|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_ALBUM_DESIGN|escape:javascript}}')) {
    a = document.createElement('a');
    a.style.fontSize = '10px';
    a.href = '#';
    a.appendChild(document.createTextNode('Info'));
    a.onclick = function() { var func1 = function() { _self._popupBox2._close(); };
                             var div = document.createElement('div');
                             MiscUtils.dialog(_self._popupBox2, DOMUtils.findPos(this), div, func1, null, {t: _self._item.title, width: 520, height: 100});
                             
                             new DialogDetails(div, _self._item, { orderId: _self._item.orderId, hidePrice: _self._options.hidePrice });
                             return false;
                           };
    this._gui.name.appendChild(a);
    if (this._item.cancelled == 1) {
      a.style.textDecoration = 'line-through';
    }
  }
  
  if (this._item.cancelled == 0) {
    var note = document.createElement('img');
    note.src = (this._item.v2_notes.length != 0) ? 'images/buttons/note_hilight.png' : 'images/buttons/note.png';
    note.style.cursor = 'pointer';
    note.style.margin = '0 0 0 5px';
    note._produce = this._item;
    note.onclick = function() { var div, pos, func1, func2;
                                var pro = this._produce;
                                div = document.createElement('div');
                                pos = DOMUtils.findPos(this);
                                MiscUtils.dialog(_self._popupBox2, pos, div, null, null, {t: pro.title, width: 760, height: 100});
                                new DialogProduceNote(div, pro, { author: _self._user, now: _self._date, popupBox: _self._popupBox2, callbackFunc: function() { _self._callbackFunc();} });
                                return false;
                              };
    this._gui.name.appendChild(note);
  }

  if (this._item.cancelled == 1) {
    span.style.textDecoration = 'line-through';
    this._gui.name.style.textDecoration = 'line-through';
  }
  
  this._gui.designer.appendChild(document.createTextNode(this._item.user_account));
  if ( this._parent.disposalstatus == 0 && this._item.cancelled == 0 && this._item.user_account != '' && (
      (this._item.pi_model == Constant.MODEL_NAME_PRODUCT_4X6 && this._item.state < 9 && this._item.state > 2) || 
      (this._item.pi_model == Constant.MODEL_NAME_PRODUCT_RETOUCH && this._item.state < 12 && this._item.state > 2) || 
      (this._item.pi_model == Constant.MODEL_NAME_PRODUCT_COMMON && this._item.state < 12 && this._item.state > 2) || 
      (this._item.pi_model == Constant.MODEL_NAME_ALBUM_DESIGN && this._item.state < 12 && this._item.state > 2)
     )) {
    a = document.createElement('a');
    a.style.fontSize = '10px';
    a.href = '#';
    a.appendChild(document.createTextNode('Chg'));
    a.onclick = function() { DlmanageUtils.change(_self._popupBox, DOMUtils.findPos(this), _self._callbackFunc, _self._item, _self._user, _self._date, { func: function(div, produce, condition) {new DialogAssignee(div, produce, { php: Constant.FACTORY + '/customphp/mysqlread.php', condition: condition }); } });
                             return false;
                           };
    this._gui.designer.appendChild(a);
  }
  
  gui = GuiProduce.instance(this._gui.task, this._gui.dateline, this._gui.progress);
  new HandleProduce(gui, this._item, this._options);
};